package pers.cz.codegen.describe;

import pers.cz.jefconfig.tools.StringUtils;

/**
 * @program: jef-code-generator
 * @description: 一个简单Pojo类类型
 * @author: Cheng Zhi
 * @create: 2022-08-07 15:36
 **/
public class SimpleClass implements IClass {
    String name;

    public SimpleClass(String name) {
        this.name = name;
    }

    public SimpleClass(Class clazz) {
        this.name = clazz.getName();
    }

    /**
     * 返回一个类全名
     * @return
     */
    @Override
    public String getName() {
        return name;
    }

    /**
     * 返回一个类名
     * @return
     */
    @Override
    public String getSimpleName() {
        if (name.contains(".")) {
            return StringUtils.subStringLast(name,".");
        }
        return name;
    }

    @Override
    public boolean isArray() {
        return false;
    }

    @Override
    public boolean isBaseType() {

        for (String baseType : BASE_TYPES) {
            if (baseType.equals(name)) {
                return true;
            }
        }
        return false;
    }
}
